<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>修改密码</title>
    <link href="js/postJs.js">
    <link href="../../个人中心/css/bootstrap.css" type="text/css" rel="stylesheet">
    <link href="../../个人中心/css/bootstrap-theme.min.css" type="text/css" rel="stylesheet">
    <link href="../../个人中心/css/bootstrap-theme.css" type="text/css" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="http://apps.bdimg.com/libs/bootstrap/3.3.4/css/bootstrap.css">
    <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <script src="http://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script>
    <script src="../../js/comfirmLogin.js"></script>
    <script src="../main/js/postJs.js"></script>
    <link href="js/component.css" rel="stylesheet">
    <script src="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css"
          integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u"
          crossorigin="anonymous">
    <script type="text/javascript">
        $(document).ready(function(){
            var error = false;

            $("#username").blur(function(){
                var username = $("#username").val();
                if(username == '') {
                    showError('username', '账户不能为空');
                    error = true;
                    return;
                }

                $.post("modifyPassProcess.php", {flag:1, username:username}, function(data){
                    if(data) {
                        $("#username").css({"border-color":"green"});
                        $("#usernameTip").css({"display":"none"});
                    } else {
                        showError('username', '账户不存在');
                        error = true;
                    }
                });
            });

            $("#oldpass").blur(function(){
                var username = $("#username").val();
                if(username=='') {
                    showError('username', '账户不能为空');
                    error = true;
                    return;
                }

                var oldpass = $("#oldpass").val();
                if(oldpass =='') {
                    showError('oldpass', '密码不能为空');
                    error = true;
                    return;
                }

                $.post("modifyPassProcess.php", {flag:2, username:username, oldpass:oldpass}, function(data){
                    if(data) {
                        $("#oldpass").css({"border-color":"green"});
                        $("#oldpassTip").css({"display":"none"});
                    } else {
                        showError('oldpass', '密码错误');
                        error = true;
                    }
                });
            });

            $("#newpass").blur(function(){
                var newpass = $("#newpass").val();
                if(newpass == '') {
                    showError('newpass', '新密码不能为空');
                    error = true;
                }
                else {
                    $("#newpass").css({"border-color":"green"});
                    $("#newpassTip").css({"display":"none"});
                }
            });

            $("#newpassAgain").blur(function(){
                var newpass = $("#newpass").val();
                if(newpass == '') {
                    showError('newpass', '新密码不能为空');
                    error = true;
                    return;
                }

                var newpassAgain = $("#newpassAgain").val();
                if(newpassAgain != newpass) {
                    showError('newpassAgain', '与输入的新密码不一致');
                    error = true;
                }
                else {
                    $("#newpassAgain").css({"border-color":"green"});
                    $("#newpassAgainTip").css({"display":"none"});
                }
            });

            $("#submit").click(function(event){
                $("#username").blur();
                $("#oldpass").blur();
                $("#newpass").blur();
                $("#newpassAgain").blur();

                if(!error) {
                    var username = $("#username").val();
                    var newpass = $("#newpass").val();
                    $.post('modifyPassProcess.php', {flag:3, username:username, newpass:newpass}, function(data) {
                        $("#modifySuccess").css({'display':'inline'});
                    });
                }

                event.preventDefault();
                return false;
            });
        });

        function showError(formSpan, errorText) {
            $("#" + formSpan).css({"border-color":"red"});
            $("#" + formSpan + "Tip").empty();
            $("#" + formSpan + "Tip").append(errorText);;
            $("#" + formSpan + "Tip").css({"display":"inline"});
        }
    </script>
    <style type="text/css">
        .container-1{
            margin-left: auto;
            margin-right: auto;
        }
    </style>
    <script type="text/javascript">
      function confirmLogin1() {
        var cookie=getCookie('userId');
        if(cookie==""){
          window.location.href='../../index.html';
        }
        else
          window.location.href='../../login_index.html';
      }
      function getCookie(c_name)
      {
        if (document.cookie.length>0)
        {
          c_start=document.cookie.indexOf(c_name + "=")
          if (c_start!=-1)
          {
            c_start=c_start + c_name.length+1
            c_end=document.cookie.indexOf(";",c_start)
            if (c_end==-1) c_end=document.cookie.length
            return unescape(document.cookie.substring(c_start,c_end))
          }
        }
        return ""
      }
    </script>
</head>
<body>
<div class="container-1" style="width: 1200px;">
<div class="navbar navbar-default" id="bs-example-navbar-collapse-1" style="height: 60px;clear: both">
    <img class="navbar-brand" id="img"  src="../../images/REALM1253AO.png" style="height: 80px;margin-left: 0px;margin-top: 8px;" onclick="confirmLogin1()">


    <style type="text/css">
        #img {
            position: absolute;
            top: -20px;
            left: 100px;
            height: 100px;

        }

    </style>
    <ul class="nav navbar-nav list-inline text-right" id="linka" style="margin-left:50%">
               
        <li><a href="../../PingtaiJieshao.html">平台介绍 <span class="sr-only">(current)</span></a></li> 
        <li><a href="../../HowUse.html">如何使用 <span class="sr-only">(current)</span></a></li>
        <li><a href="#" onclick="dogo()">客服服务<span class="sr-only">(current)</span></a></li>
        <script type="text/javascript">
            function dogo(){
                var urls = new Array();
                urls[0] = "tencent://message/?uin=1298751988;Site=http://localhost:63342/GongYeHuaPingTaiQianDuan/%E4%B8%BB%E9%A1%B5/index.html;menu=yes";
                urls[1] = "tencent://message/?uin=你的QQ号码;Site=你的网址;menu=yes";
                n = Math.floor(Math.random()*2);
                location.href= urls[n];
            };
        </script>
        <!-- 联系我们-->
        <li><a href="../../ContactUs.html" class="md-trigger btn" data-modal="modal-4">联系我们<span class="sr-only">(current)</span></a>
        </li>
        <li><a href="../../个人中心/HTML/homepage.html">返回主页 <span class="sr-only">(current)</span></a></li>
             
    </ul>
</div>
<hr/>

<div class=".container" style="margin-top:5%;margin-left: 35%">
    <form class="form-horizontal" role="form">
        <div class="form-group">
            <label for="username" class="col-sm-2 control-label" style="font-size: 21px">账户</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" style="width:250px;height:40px" id="username" placeholder="请输入用户名"><span id="usernameTip" style="display:none;color:red;"></span>
            </div>
        </div>
        <div class="form-group">
            <label for="oldpass" class="col-sm-2 control-label"style="font-size: 21px">旧密码</label>
            <div class="col-sm-10">
                <input type="password" class="form-control" style="width:250px;;height:40px" id="oldpass" placeholder="请输入旧密码"><span id="oldpassTip" style="display:none;color:red;"></span>
            </div>
        </div>
        <div class="form-group">
            <label for="newpass" class="col-sm-2 control-label"style="font-size: 21px">新密码</label>
            <div class="col-sm-10">
                <input type="password" class="form-control" style="width:250px;;height:40px" id="newpass" placeholder="请输入新密码"><span id="newpassTip" style="display:none;color:red;"></span>
            </div>
        </div>
        <div class="form-group">
            <label for="newpassAgain" class="col-sm-2 control-label"style="font-size: 21px">确认新密码</label>
            <div class="col-sm-10">
                <input type="password" class="form-control" style="width:250px;;height:40px" id="newpassAgain" placeholder="请再次输入新密码"><span id="newpassAgainTip" style="display:none;color:red;"></span>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">  </label>
            <button onclick="rePassword()" type="submit" class="btn btn-primary" id="submit" style="margin-top: 30px;height: 40px;width:100px;text-align:center;">确认修改</button>
        </div>
    </form>
</div>
<div style="position: fixed;
     bottom: 0;
     left: 0;
     right: 0;;height: auto;width: 100%;padding-top:5px;;background: #f8f8f8;
            ;font-family: Arial; font-size: 12px;letter-spacing: 1px;">
    <p style="text-align: center">Dover,DE 19901</p>
    <p style="text-align: center">(123)456-7890</p>
    <p style="text-align: center">©2017 MB Flowers</p>
</div>
</div>
</body>
</html>